package com.since.data_structure.binarytree;

import com.since.data_structure.binarytree.node.Node;

/**
 * Created by Sincerity on 2020/5/21.
 * 描述：线索化二叉树
 */
class ThreadedBinaryTree {
    public static void main(String[] args) {
        System.out.println("使用线索化的方式遍历 线索化二叉树");
        Node root = new Node(1);
        Node node2 = new Node(3);
        Node node3 = new Node(6);
        Node node4 = new Node(8);
        Node node5 = new Node(10);
        Node node6 = new Node(14);

        //二叉树，后面我们要递归创建, 现在简单处理使用手动创建
        root.setLeft(node2);
        root.setRight(node3);
        node2.setLeft(node4);
        node2.setRight(node5);
        node3.setLeft(node6);

        //测试中序线索化
        BinaryTree tree = new BinaryTree();
        tree.setRoot(root);
        tree.threadedNodes(root);
        tree.threadedBinaryTree();//8, 3, 10, 1, 14, 6
    }
}
